package com.cqie.practicaltraining.controller;

import com.cqie.practicaltraining.config.result.R;
import com.cqie.practicaltraining.service.impl.CityServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/city")
@Api(value = "城市管理")
public class cityController {
    @Autowired
    private CityServiceImpl cityService;

    @GetMapping("/getNameByParentId")
    @ApiOperation(value = "通过父级id获取下一级城市名称")
    public R getNameByParentId(@RequestParam(required = false) String cityName){
        return cityService.getNameByParentId(cityName);
    }

    @GetMapping("/getAllCity")
    @ApiOperation(value = "获取所有城市信息")
    public R getAllCity(){
        return cityService.getAllCity();
    }

    @PostMapping("/getCityNameByCityId")
    @ApiOperation(value = "通过城市id获取城市名称")
    public R getCityNameByCityId(@RequestParam int cityId){
        return cityService.getCityNameByCityId(cityId);
    }
}
